package com.topscomm.mis.cbb.pm.controller;

import com.topscomm.basic.exception.ServiceException;
import com.topscomm.mis.cbb.pm.api.IWbsService;
import com.topscomm.mis.cbb.pm.controller.auto.CbbPmWbsControllerAuto;
//import com.topscomm.mis.cbb.pm.util.TaskTreeModel;
import com.topscomm.mis.cbb.pm.util.PmSystemConst;
import com.topscomm.pub.vo.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("cbb/pmWbs")
public class CbbPmWbsController extends CbbPmWbsControllerAuto {
    @Autowired
    private IWbsService wbsService;

    /***
     * @description: 调试使用
     * @param paraMap
     * @return com.topscomm.pub.vo.ResponseResult
     * @author: hudeyong
     * @date: 2023/6/14 8:53
     * @modify:
     */
    @GetMapping(value = "/createWbs")
    public ResponseResult createWbs(@RequestParam(required = false) Map<String, Object> paraMap) {
        paraMap.put("uuCode","PRO23071200004");
        paraMap.put("flowId","23060900000002");
        paraMap.put("sourceId","23071200000012");
        paraMap.put("sourceType","CSI_PM_PROJECT_DETAIL");
        paraMap.put("flowInsId","23071200003011");
//        paraMap.put("startNodeId","23062700002004");
//        paraMap.put("endNodeId","23062700002009");
        paraMap.put("operateType", PmSystemConst.OperateWbsType.CREATE);
        wbsService.operateWbs(paraMap);
        return ResponseResult.ok("");
    }

    /***
     * @description: 查找wbs任务树
     * @param paraMap
     * @return
     * @author: hudeyong
     * @date: 2023/6/16
     * @modify:
     */
    @GetMapping(value = "/queryWbsTreeList")
    public ResponseResult queryWbsTreeList(@RequestParam(required = false) Map<String, Object> paraMap) {
        String usercode = this.getUserBean().getUser().getCode();
        paraMap.put("usercode",usercode);
        List<Map<String, Object>> treeList = wbsService.createWbsTreeList(paraMap);
        Map<String, Object> resultMap = new HashMap<>();
        resultMap.put("dataList",treeList);
        return ResponseResult.ok(resultMap);
    }
}
